//
//  DevelopDetailViewController.swift
//  HuaYun
//
//  Created by enghou on 2019/1/15.
//  Copyright © 2019 xyxorigation. All rights reserved.
//

import UIKit

class DevelopDetailViewController: ProjectIncomCostDetailViewController {

    
    var id = ""
    var orgid = ""
    override func viewDidLoad() {
        super.viewDidLoad()
        NotificationCenter.default.addObserver(self, selector: #selector(refresh(not:)), name: NSNotification.Name("RefreshDetail"), object: nil)
    }
    
    override func param(for name: String) -> Dictionary<String, Any> {
        return ["orderType": self.orderType,"planId": self.id,"start": self.start,"end": self.end]
    }
    
    @objc override func refresh(not: Notification){
        if let obj = not.object as? Int {
            self.orderType = obj
            self.load(with: self.names[0])
        }
    }
    
    override func configViewControllers() -> [UIViewController] {
        return [DevelopAssociateViewController(),TitleContentTableViewController()]
    }
    
    override func path(for name: String) -> String {
        return DevelopFeeDetail
    }
    
    override func success(for name: String) -> NetSuccess {
        func suc(json: JSON){
            let base = self.ctls[1] as! TitleContentTableViewController
            var contents: Array<Dictionary<String,String?>> = []
            contents.append(["综合计划编号:": json["data"]["serialnumber"].string])
            contents.append(["综合计划名称:": json["data"]["compositeName"].string])
            let cost = (json["data"]["cost"].int ?? 0) / 100
            contents.append(["成本(元):": String(cost).rmbformat])
            base.source = contents
            base.tableView.reloadData()
            let listctl = self.ctls[0] as! IncomeCostProjects
            listctl.source = json["data"]["listProj"].array ?? []
            listctl.tableView.reloadData()
        }
        return suc
    }
    
    override func configTitles() -> Array<String> {
        return ["关联项目","基本信息"]
    }

}
